export default function(time) {
    return {
        data() {
            return {
                timeFlag: false,
                time,
                mytime: '',
            };
        },
        methods: {
            timeEnd() {
                this.timeFlag = false;
                this.time = time;
                clearInterval(this.mytime);
            },
            timeInit() {
                this.timeFlag = true;
                this.mytime = setInterval(() => {
                    this.time--;
                    if (this.time < 0) {
                        this.timeEnd();
                    }
                }, 1000);
            },
        },
    };
}